package com.jic.finance.impl;

import java.lang.Long;
import java.util.List;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.finance.entity.PaymentGatewayConfig;
import com.jic.finance.mapper.PaymentGatewayConfigMapper;
import com.jic.finance.service.PaymentGatewayConfigService;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 支付网关配置表
 * @author : 
 * @email : 
 * @since : 2020-03-04 10:48:57
 * @version : v1.0.0
 */
@Service
public class PaymentGatewayConfigServiceImpl implements PaymentGatewayConfigService{

    @Autowired
    private PaymentGatewayConfigMapper paymentGatewayConfigMapper;

    @Override
    public long insert(PaymentGatewayConfig paymentGatewayConfig) {
        long flag = paymentGatewayConfigMapper.insert(paymentGatewayConfig);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return paymentGatewayConfigMapper.delete(id);
    }

    @Override
    public long update(PaymentGatewayConfig paymentGatewayConfig) {
        return paymentGatewayConfigMapper.update(paymentGatewayConfig);
    }

    @Override
    public PaymentGatewayConfig queryByPrimaryKey(Long id){
        return paymentGatewayConfigMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<PaymentGatewayConfig> query(PaymentGatewayConfig paymentGatewayConfig){
        return paymentGatewayConfigMapper.query(paymentGatewayConfig);
    }

    @Override
    public PageResult<PaymentGatewayConfig> queryPage(PaymentGatewayConfig paymentGatewayConfig, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<PaymentGatewayConfig> list = paymentGatewayConfigMapper.queryPage(startIndex, pageQuery.getLimit(), paymentGatewayConfig);
        long count = paymentGatewayConfigMapper.queryPageCount(paymentGatewayConfig);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}